<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Str;
use Log;
use App\Models\Slideshow;
use App\Models\Setting;

class ShopController extends Controller
{
    /**
     * @api {post} /slideshow/list
     * 首页轮播列表
     */
    public function slideshowList(Request $request)
    {
        $data = Slideshow::getList();

        return $this->output(200, $data);
    }

    /**
     * @api {post} /payment/list
     * 获取支付方式列表
     */
    public function paymentList(Request $request)
    {
        $setting = Setting::where('code', 'payment_sumpay')->first();

        $payment_list = [];
        if (isset($setting->value))
        {
            $payment_sumpay = json_decode($setting->value, 1);

            if (isset($payment_sumpay['open']) && ($payment_sumpay['open'] ==1))
            {
                $payment_list[] = [
                    'name' => '统统付',
                    'code' => 'sumpay',
                ];
            }
        }

        return $this->output(200, $payment_list);
    }

}